/*Copyright ©2015 TommyLemon(https://github.com/TommyLemon)

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.*/

package soft.hb.activity;

import android.annotation.TargetApi;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.bumptech.glide.Glide;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

import soft.hb.R;
import soft.hb.application.HbApplication;
import soft.hb.model.SurveyRecord;
import soft.hb.model.User;
import soft.hb.util.FileUtils;
import soft.hb.util.HttpRequest;
import soft.hb.view.view.HandWriteView;
import zuo.biao.library.base.BaseActivity;
import zuo.biao.library.interfaces.OnHttpResponseListener;
import zuo.biao.library.model.Parameter;
import zuo.biao.library.ui.AlertDialog;
import zuo.biao.library.ui.BottomMenuWindow;
import zuo.biao.library.util.JSON;
import zuo.biao.library.util.Log;
import zuo.biao.library.util.SettingUtil;

/**
 * 现场检查（勘验）笔录
 *
 * @author yuanweiwei
 */
public class SurveyRecordActivity extends BaseActivity implements OnClickListener, OnHttpResponseListener, AlertDialog.OnDialogButtonClickListener {
    public static final String TAG = "SurveyRecordActivity";

    /**
     * 获取启动IndexActivity的intent
     *
     * @param context
     * @return
     */
    public static Intent createIntent(Context context) {
        return new Intent(context, SurveyRecordActivity.class);
    }


    @Override
    public Activity getActivity() {
        return this; //必须return this;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.survey_record_activity);
        intent = getIntent();

        //功能归类分区方法，必须调用<<<<<<<<<<
        initView();
        initData();
        initEvent();
        //功能归类分区方法，必须调用>>>>>>>>>>

    }


    //UI显示区(操作UI，但不存在数据获取或处理代码，也不存在事件监听代码)<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

    private TextView tvStartDate;//开始时间
    private TextView tvEndDate;//结束时间
    private TextView tvSiteLeaderDate;// 现场负责人签字日期
    private TextView tvInspectorPersonDate;//勘验人签名日期
    private TextView tvRecordPersonDate;//记录人签名日期

    private EditText editCheckedName;//检查人
    private EditText editCheckedNo;//检查人执法证号

    private EditText editLawenforcers;//检查人
    private EditText editLawenforcersNo;//检查人执法证号
    private EditText editNotetaker;//记录人
    private EditText editInspectorperson;//检测（勘验）人签名

    private EditText editInspectorperson2;//检测（勘验）人签名2
    private EditText editRecordperson;//记录人签名
    private EditText editAddress; //地址
    private EditText editUnit; //工作单位

    private EditText editInspector;//被检查人
    private EditText editLegalPerson;//法人
    private EditText editIdCard;//省份证号
    private EditText editCorporateName;//工作单位
    private EditText editJob;//职务
    private EditText editCorporateAddress; //公司地址
    private EditText editZipCode; //邮编
    private EditText editPhone; //电话
    private EditText editSomeoneElse;//其他人

    private EditText editRemarks;//现场情况
    private EditText editCarModel1;//车型
    private EditText editLicensePlate1; //车牌
    private EditText editCarModel2;//菜油车型
    private EditText editLicensePlate2; //车牌
    private CheckBox cbQtype;
    private CheckBox cbCtype;
    private ImageView ivPersonInCharge;//现场负责人签字1
    private ImageView ivSiteLeader;//现场负责人签字2
    private ImageView ivRecordSiteLeader;//现场负责人签字


    private EditText editEnforcer2;//执法人2
    private EditText editEnforcerNo2;//执法人证号2

    private EditText editEnforcer3;//执法人3
    private EditText editEnforcerNo3;//执法人证号3



    private HandWriteView handWriteView;

    @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
    @Override
    public void initView() {//必须调用
        tvStartDate = findView(R.id.tv_start_date);
        tvEndDate = findView(R.id.tv_end_date);
        tvRecordPersonDate = findView(R.id.tv_record_person_date);
        tvInspectorPersonDate = findView(R.id.tv_inspector_person_date);
        tvInspectorPersonDate = findView(R.id.tv_inspector_person_date);
        tvSiteLeaderDate = findView(R.id.tv_site_leader_date);
        editCheckedName = findView(R.id.edit_checked_name);
        editCheckedName.setOnClickListener(this);
        editCheckedNo = findView(R.id.edit_checked_no);
        editLawenforcers = findView(R.id.edit_lawenforcers);
        editLawenforcers.setOnClickListener(this);
        editLawenforcersNo = findView(R.id.edit_lawenforcers_no);
        editNotetaker = findView(R.id.edit_notetaker);
        editNotetaker.setOnClickListener(this);
        editInspectorperson = findView(R.id.edit_inspectorperson);
        editInspectorperson.setOnClickListener(this);

        editInspectorperson2 = findView(R.id.edit_inspectorperson2);
        editInspectorperson2.setOnClickListener(this);

        editRecordperson = findView(R.id.edit_recordperson);
        editRecordperson.setOnClickListener(this);

        findView(R.id.btn_submit).setOnClickListener(this);

        editAddress = findView(R.id.edit_address);
        editUnit = findView(R.id.edit_unit);
        editInspector = findView(R.id.edit_inspector);
        editLegalPerson = findView(R.id.edit_legalPerson);
        editIdCard = findView(R.id.edit_idCard);
        editCorporateName = findView(R.id.edit_corporateName);
        editJob = findView(R.id.edit_job);
        editCorporateAddress = findView(R.id.edit_corporateAddress);
        editZipCode = findView(R.id.edit_zipCode);
        editPhone = findView(R.id.edit_phone);
        editSomeoneElse = findView(R.id.edit_someoneElse);


        editRemarks = findView(R.id.edit_remarks);
        editCarModel1 = findView(R.id.edit_carModel1);
        editLicensePlate1 = findView(R.id.edit_licensePlate1);
        editCarModel2 = findView(R.id.edit_carModel2);
        editLicensePlate2 = findView(R.id.edit_licensePlate2);

        cbQtype = findView(R.id.cb_qtype);
        cbQtype.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if(isChecked){
                    cbCtype.setChecked(false);
                }
            }
        });
        cbCtype = findView(R.id.cb_ctype);
        cbCtype.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if(isChecked){
                    cbQtype.setChecked(false);
                }
            }
        });
        ivPersonInCharge = findView(R.id.iv_personInCharge);
        ivPersonInCharge.setOnClickListener(this);
        ivSiteLeader = findView(R.id.iv_siteLeader);
        ivSiteLeader.setOnClickListener(this);
        ivRecordSiteLeader = findView(R.id.iv_recordSiteLeader);
        ivRecordSiteLeader.setOnClickListener(this);



        editEnforcer2 = findView(R.id.edit_lawenforcers2);
        editEnforcer2.setOnClickListener(this);
        editEnforcerNo2 = findView(R.id.edit_lawenforcers_no2);

        editEnforcer3 = findView(R.id.edit_checked_name2);
        editEnforcer3.setOnClickListener(this);
        editEnforcerNo3 = findView(R.id.edit_checked_no2);
    }


    //UI显示区(操作UI，但不存在数据获取或处理代码，也不存在事件监听代码)>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>


    //Data数据区(存在数据获取或处理代码，但不存在事件监听代码)<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<


    private static String[] TOPBAR_COLOR_NAMES = null;
    private static List<User> DATA_USER = new ArrayList<>();
    //勘验记录
    private static SurveyRecord surveyRecord = new SurveyRecord();

    @Override
    public void initData() {//必须调用
        Calendar calendar = Calendar.getInstance();
        //获取系统的日期
        //年
        int year = calendar.get(Calendar.YEAR);
        //月
        int month = calendar.get(Calendar.MONTH) + 1;
        //日
        int day = calendar.get(Calendar.DAY_OF_MONTH);
        //获取系统时间
        //小时
        int hour = calendar.get(Calendar.HOUR_OF_DAY);
        //分钟
        int minute = calendar.get(Calendar.MINUTE);
        //秒
        int second = calendar.get(Calendar.SECOND);

        tvStartDate.setText(year + "年" + month + "月" + day + "日" + hour + "时" + minute + "分");
        tvSiteLeaderDate.setText(year + "年" + month + "月" + day + "日");
        tvInspectorPersonDate.setText(year + "年" + month + "月" + day + "日");
        tvRecordPersonDate.setText(year + "年" + month + "月" + day + "日");

        surveyRecord.setCheckStartTime(year + "-" + month + "-" + day + "  " + hour + ":" + minute);
        surveyRecord.setSiteLeaderDate(year + "-" + month + "-" + day);
        surveyRecord.setInspectorPersonDate(year + "-" + month + "-" + day);
        surveyRecord.setRecordPersonDate(year + "-" + month + "-" + day);
        surveyRecord.setSubmitype("1");
        showProgressDialog(R.string.loading);
        HttpRequest.getUserList(0, new OnHttpResponseListener() {
            @Override
            public void onHttpResponse(int requestCode, String resultJson, Exception e) {
                JSONObject jsonObject = JSON.parseObject(resultJson);
                JSONArray data = jsonObject == null ? null : jsonObject.getJSONArray("data");
                Log.i(TAG, data.toJSONString());
                if (data != null && data.size() > 0) {
                    TOPBAR_COLOR_NAMES = new String[data.size()];
                    for (int i = 0; i < data.size(); i++) {
                        JSONObject jo = data.getJSONObject(i);
                        User user = JSON.parseObject(jo, User.class);
                        DATA_USER.add(user);
                        TOPBAR_COLOR_NAMES[i] = user.getName();
                    }
                }
                dismissProgressDialog();
            }
        });
    }

    //Data数据区(存在数据获取或处理代码，但不存在事件监听代码)>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>


    //Event事件区(只要存在事件监听代码就是)<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

    @Override
    public void initEvent() {//必须调用
    }


    //系统自带监听方法<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<


    @Override
    public void onDialogButtonClick(int requestCode, boolean isPositive) {
        if (! isPositive) {
            return;
        }

        switch (requestCode) {
            case 0:
                Calendar calendar = Calendar.getInstance();
                //获取系统的日期
                //年
                int year = calendar.get(Calendar.YEAR);
                //月
                int month = calendar.get(Calendar.MONTH) + 1;
                //日
                int day = calendar.get(Calendar.DAY_OF_MONTH);
                //获取系统时间
                //小时
                int hour = calendar.get(Calendar.HOUR_OF_DAY);
                //分钟
                int minute = calendar.get(Calendar.MINUTE);
//                showShortToast(surveyRecord.getInspectorPerson() +"----"+surveyRecord.getRecordPerson());
                surveyRecord.setAddress(editAddress.getText().toString());
                surveyRecord.setWorkUnit(editUnit.getText().toString());
                surveyRecord.setInspector(editInspector.getText().toString());
                surveyRecord.setLegalPerson(editLegalPerson.getText().toString());
                surveyRecord.setIdCard(editIdCard.getText().toString());
                surveyRecord.setCorporateName(editCorporateName.getText().toString());
                surveyRecord.setJob(editJob.getText().toString());
                surveyRecord.setCorporateAddress(editCorporateAddress.getText().toString());
                surveyRecord.setZipCode(editZipCode.getText().toString());
                surveyRecord.setPhone(editPhone.getText().toString());
                surveyRecord.setRemarks(editRemarks.getText().toString());
                surveyRecord.setSomeoneElse(editSomeoneElse.getText().toString());

                ///////////////////////////////////////非空校验


                ///////////////////////////////////////非空校验

                if (cbQtype.isChecked()){
                    surveyRecord.setCarType("1");
                    surveyRecord.setCarModel(editCarModel1.getText().toString());
                    surveyRecord.setLicensePlate(editLicensePlate1.getText().toString());
                }

                if (cbCtype.isChecked()){
                    surveyRecord.setCarType("2");
                    surveyRecord.setCarModel(editCarModel2.getText().toString());
                    surveyRecord.setLicensePlate(editLicensePlate2.getText().toString());
                }
                surveyRecord.setCheckEndTime(year + "-" + month + "-" + day + "  " + hour + ":" + minute);
                showProgressDialog(R.string.loading);
                HttpRequest.submitRecord(surveyRecord, 0, new OnHttpResponseListener() {
                    @Override
                    public void onHttpResponse(int requestCode, String resultJson, Exception e) {
                        dismissProgressDialog();
                        JSONObject jsonObject = JSON.parseObject(resultJson);
                        if(jsonObject.getBoolean("success")){
                            //提交成功
                            showShortToast(R.string.add_succeed);
                            finish();
                        }else{
                            showShortToast(jsonObject.getString("msg"));
                        }
                    }
                });

                break;
            default:
                break;
        }
    }


    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.btn_submit:

                new AlertDialog(this, "提交记录", "确定表单是否填写完整并提交？", true, 0, this).show();

                break;

            case R.id.edit_checked_name:
                if (TOPBAR_COLOR_NAMES != null && TOPBAR_COLOR_NAMES.length > 0) {
                    toActivity(BottomMenuWindow.createIntent(context, TOPBAR_COLOR_NAMES)
                            .putExtra(BottomMenuWindow.INTENT_TITLE, "选择检查人员"), REQUEST_TO_BOTTOM_MENU, false);
                }
                break;
            case R.id.edit_lawenforcers:
                if (TOPBAR_COLOR_NAMES != null && TOPBAR_COLOR_NAMES.length > 0) {
                    toActivity(BottomMenuWindow.createIntent(context, TOPBAR_COLOR_NAMES)
                            .putExtra(BottomMenuWindow.INTENT_TITLE, "选择检查人员"), REQUEST_TO_BOTTOM_MENU2, false);
                }
                break;
            case R.id.edit_notetaker:
                if (TOPBAR_COLOR_NAMES != null && TOPBAR_COLOR_NAMES.length > 0) {
                    toActivity(BottomMenuWindow.createIntent(context, TOPBAR_COLOR_NAMES)
                            .putExtra(BottomMenuWindow.INTENT_TITLE, "选择检查人员"), REQUEST_TO_BOTTOM_MENU3, false);
                }
                break;
            case R.id.edit_inspectorperson:
                if (TOPBAR_COLOR_NAMES != null && TOPBAR_COLOR_NAMES.length > 0) {
                    toActivity(BottomMenuWindow.createIntent(context, TOPBAR_COLOR_NAMES)
                            .putExtra(BottomMenuWindow.INTENT_TITLE, "选择检查人员"), REQUEST_TO_BOTTOM_MENU4, false);
                }
                break;
            case R.id.edit_inspectorperson2:
                if (TOPBAR_COLOR_NAMES != null && TOPBAR_COLOR_NAMES.length > 0) {
                    toActivity(BottomMenuWindow.createIntent(context, TOPBAR_COLOR_NAMES)
                            .putExtra(BottomMenuWindow.INTENT_TITLE, "选择检查人员"), REQUEST_TO_BOTTOM_MENU8, false);
                }
                break;
            case R.id.edit_recordperson:
                if (TOPBAR_COLOR_NAMES != null && TOPBAR_COLOR_NAMES.length > 0) {
                    toActivity(BottomMenuWindow.createIntent(context, TOPBAR_COLOR_NAMES)
                            .putExtra(BottomMenuWindow.INTENT_TITLE, "选择检查人员"), REQUEST_TO_BOTTOM_MENU5, false);
                }
                break;
            case R.id.iv_siteLeader:
                final Dialog dialog = new Dialog(this, R.style.Theme_Light_Dialog);
                View dialogView = LayoutInflater.from(this).inflate(R.layout.sign_dialog,null);
                //获得dialog的window窗口
                Window window = dialog.getWindow();
                //设置dialog在屏幕底部
                window.setGravity(Gravity.BOTTOM);
                //设置dialog弹出时的动画效果，从屏幕底部向上弹出
                window.setWindowAnimations(R.style.dialogStyle);
                window.getDecorView().setPadding(0, 0, 0, 0);
                //获得window窗口的属性
                android.view.WindowManager.LayoutParams lp = window.getAttributes();
                //设置窗口宽度为充满全屏
                lp.width = WindowManager.LayoutParams.MATCH_PARENT;
                //设置窗口高度为包裹内容
                lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
                //将设置好的属性set回去
                window.setAttributes(lp);
                //将自定义布局加载到dialog上
                dialog.setContentView(dialogView);
                handWriteView =  (HandWriteView)dialogView.findViewById(R.id.view);
                dialogView.findViewById(R.id.clear).setOnClickListener(this);
                dialogView.findViewById(R.id.save).setOnClickListener(new OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        if (handWriteView.isSign())
                            try {
                                showProgressDialog(R.string.loading);
                                String path = Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + new Date().getTime()+".png";
                                handWriteView.save(path, true, 10,true);
                                HttpRequest.uploadSign(FileUtils.encodeToString(path), 0, new OnHttpResponseListener() {
                                    @Override
                                    public void onHttpResponse(int requestCode, String resultJson, Exception e) {
                                        JSONObject jsonObject = JSON.parseObject(resultJson);
                                        if(jsonObject.getBoolean("success")){
                                            surveyRecord.setSiteLeader(jsonObject.getString("msg"));
                                            Glide.with(SurveyRecordActivity.this).load(SettingUtil.URL_SERVER_IMG+jsonObject.getString("msg")).into(ivSiteLeader);
                                            dismissProgressDialog();
                                            dialog.dismiss();
                                        }else{
                                            dismissProgressDialog();
                                            dialog.dismiss();
                                            showShortToast(jsonObject.getString("msg"));
                                        }
                                    }
                                });
                            } catch (IOException e) {
                                e.printStackTrace();
                            }
                        else {
                            showShortToast("还没有签名！");
                        }
                    }
                });
                dialog.show();
                break;
            case R.id.clear:
                handWriteView.clear();
                break;
            case R.id.iv_recordSiteLeader:
                final Dialog dialog1 = new Dialog(this, R.style.Theme_Light_Dialog);
                View dialogView1 = LayoutInflater.from(this).inflate(R.layout.sign_dialog,null);
                //获得dialog的window窗口
                Window window1 = dialog1.getWindow();
                //设置dialog在屏幕底部
                window1.setGravity(Gravity.BOTTOM);
                //设置dialog弹出时的动画效果，从屏幕底部向上弹出
                window1.setWindowAnimations(R.style.dialogStyle);
                window1.getDecorView().setPadding(0, 0, 0, 0);
                //获得window窗口的属性
                android.view.WindowManager.LayoutParams lp1 = window1.getAttributes();
                //设置窗口宽度为充满全屏
                lp1.width = WindowManager.LayoutParams.MATCH_PARENT;
                //设置窗口高度为包裹内容
                lp1.height = WindowManager.LayoutParams.WRAP_CONTENT;
                //将设置好的属性set回去
                window1.setAttributes(lp1);
                //将自定义布局加载到dialog上
                dialog1.setContentView(dialogView1);
                handWriteView =  (HandWriteView)dialogView1.findViewById(R.id.view);
                dialogView1.findViewById(R.id.clear).setOnClickListener(this);
                dialogView1.findViewById(R.id.save).setOnClickListener(new OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        if (handWriteView.isSign())
                            try {
                                showProgressDialog(R.string.loading);
                                String path = Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + new Date().getTime()+".png";
                                handWriteView.save(path, true, 10,true);
                                HttpRequest.uploadSign(FileUtils.encodeToString(path), 0, new OnHttpResponseListener() {
                                    @Override
                                    public void onHttpResponse(int requestCode, String resultJson, Exception e) {
                                        JSONObject jsonObject = JSON.parseObject(resultJson);
                                        if(jsonObject.getBoolean("success")){
                                            surveyRecord.setRecordSiteLeader(jsonObject.getString("msg"));
                                            Glide.with(SurveyRecordActivity.this).load(SettingUtil.URL_SERVER_IMG+jsonObject.getString("msg")).into(ivRecordSiteLeader);
                                            dismissProgressDialog();
                                            dialog1.dismiss();
                                        }else{
                                            dismissProgressDialog();
                                            dialog1.dismiss();
                                            showShortToast(jsonObject.getString("msg"));
                                        }
                                    }
                                });
                            } catch (IOException e) {
                                e.printStackTrace();
                            }
                        else {
                            showShortToast("还没有签名！");
                        }
                    }
                });
                dialog1.show();
                break;
            case R.id.iv_personInCharge:
                final Dialog dialog2 = new Dialog(this, R.style.Theme_Light_Dialog);
                View dialogView2 = LayoutInflater.from(this).inflate(R.layout.sign_dialog,null);
                //获得dialog的window窗口
                Window window2 = dialog2.getWindow();
                //设置dialog在屏幕底部
                window2.setGravity(Gravity.BOTTOM);
                //设置dialog弹出时的动画效果，从屏幕底部向上弹出
                window2.setWindowAnimations(R.style.dialogStyle);
                window2.getDecorView().setPadding(0, 0, 0, 0);
                //获得window窗口的属性
                android.view.WindowManager.LayoutParams lp2 = window2.getAttributes();
                //设置窗口宽度为充满全屏
                lp2.width = WindowManager.LayoutParams.MATCH_PARENT;
                //设置窗口高度为包裹内容
                lp2.height = WindowManager.LayoutParams.WRAP_CONTENT;
                //将设置好的属性set回去
                window2.setAttributes(lp2);
                //将自定义布局加载到dialog上
                dialog2.setContentView(dialogView2);
                handWriteView =  (HandWriteView)dialogView2.findViewById(R.id.view);
                dialogView2.findViewById(R.id.clear).setOnClickListener(this);
                dialogView2.findViewById(R.id.save).setOnClickListener(new OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        if (handWriteView.isSign())
                            try {
                                showProgressDialog(R.string.loading);
                                String path = Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + new Date().getTime()+".png";
                                handWriteView.save(path, true, 10,true);
                                HttpRequest.uploadSign(FileUtils.encodeToString(path), 0, new OnHttpResponseListener() {
                                    @Override
                                    public void onHttpResponse(int requestCode, String resultJson, Exception e) {
                                        JSONObject jsonObject = JSON.parseObject(resultJson);
                                        if(jsonObject.getBoolean("success")){
                                            surveyRecord.setPersonInCharge(jsonObject.getString("msg"));
                                            Glide.with(SurveyRecordActivity.this).load(SettingUtil.URL_SERVER_IMG+jsonObject.getString("msg")).into(ivPersonInCharge);
                                            dismissProgressDialog();
                                            dialog2.dismiss();
                                        }else{
                                            dismissProgressDialog();
                                            dialog2.dismiss();
                                            showShortToast(jsonObject.getString("msg"));
                                        }
                                    }
                                });
                            } catch (IOException e) {
                                e.printStackTrace();
                            }
                        else {
                            showShortToast("还没有签名！");
                        }
                    }
                });
                dialog2.show();
                break;

            case R.id.edit_checked_name2:
                if (TOPBAR_COLOR_NAMES != null && TOPBAR_COLOR_NAMES.length > 0) {
                    toActivity(BottomMenuWindow.createIntent(context, TOPBAR_COLOR_NAMES)
                            .putExtra(BottomMenuWindow.INTENT_TITLE, "选择检查人员"), REQUEST_TO_BOTTOM_MENU7, false);
                }
                break;

            case R.id.edit_lawenforcers2:
                if (TOPBAR_COLOR_NAMES != null && TOPBAR_COLOR_NAMES.length > 0) {
                    toActivity(BottomMenuWindow.createIntent(context, TOPBAR_COLOR_NAMES)
                            .putExtra(BottomMenuWindow.INTENT_TITLE, "选择检查人员"), REQUEST_TO_BOTTOM_MENU6, false);
                }
                break;
        }
    }


    //类相关监听<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

    private static final int REQUEST_TO_BOTTOM_MENU = 1;
    private static final int REQUEST_TO_BOTTOM_MENU2 = 2;
    private static final int REQUEST_TO_BOTTOM_MENU3 = 3;
    private static final int REQUEST_TO_BOTTOM_MENU4 = 4;
    private static final int REQUEST_TO_BOTTOM_MENU5 = 5;
    private static final int REQUEST_TO_BOTTOM_MENU6 = 6;
    private static final int REQUEST_TO_BOTTOM_MENU7 = 7;
    private static final int REQUEST_TO_BOTTOM_MENU8 = 8;

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (resultCode != RESULT_OK) {
            return;
        }
        switch (requestCode) {
            case REQUEST_TO_BOTTOM_MENU:
                if (data != null) {
                    int position = data.getIntExtra(BottomMenuWindow.RESULT_ITEM_ID, -1);
                    if (position >= 0) {
                        editCheckedName.setText(DATA_USER.get(position).getName());
                        editCheckedNo.setText(DATA_USER.get(position).getNo());
                        surveyRecord.setCardNo(DATA_USER.get(position).getNo());
                    }
                }
                break;

            case REQUEST_TO_BOTTOM_MENU2:
                if (data != null) {
                    int position = data.getIntExtra(BottomMenuWindow.RESULT_ITEM_ID, -1);
                    if (position >= 0) {
                        editLawenforcers.setText(DATA_USER.get(position).getName());
                        editLawenforcersNo.setText(DATA_USER.get(position).getNo());
                        surveyRecord.setLawEnforcers(DATA_USER.get(position).getStrId());
                        surveyRecord.setLawEnforcersNo(DATA_USER.get(position).getNo());
                    }
                }
                break;
            case REQUEST_TO_BOTTOM_MENU3:
                if (data != null) {
                    int position = data.getIntExtra(BottomMenuWindow.RESULT_ITEM_ID, -1);
                    if (position >= 0) {
                        editNotetaker.setText(DATA_USER.get(position).getName());
                        surveyRecord.setNoteTaker(DATA_USER.get(position).getStrId());
                    }
                }
                break;
            case REQUEST_TO_BOTTOM_MENU4:
                if (data != null) {
                    int position = data.getIntExtra(BottomMenuWindow.RESULT_ITEM_ID, -1);
                    if (position >= 0) {
                        editInspectorperson.setText(DATA_USER.get(position).getName());
                        surveyRecord.setInspectorPerson(DATA_USER.get(position).getStrId());
                    }
                }
                break;
            case REQUEST_TO_BOTTOM_MENU8:
                if (data != null) {
                    int position = data.getIntExtra(BottomMenuWindow.RESULT_ITEM_ID, -1);
                    if (position >= 0) {
                        editInspectorperson2.setText(DATA_USER.get(position).getName());
                        surveyRecord.setInspectorPerson2(DATA_USER.get(position).getStrId());
                    }
                }
                break;
            case REQUEST_TO_BOTTOM_MENU5:
                if (data != null) {
                    int position = data.getIntExtra(BottomMenuWindow.RESULT_ITEM_ID, -1);
                    if (position >= 0) {
                        editRecordperson.setText(DATA_USER.get(position).getName());
                        surveyRecord.setRecordPerson(DATA_USER.get(position).getStrId());
                    }
                }
                break;
            case REQUEST_TO_BOTTOM_MENU6:
                if (data != null) {
                    int position = data.getIntExtra(BottomMenuWindow.RESULT_ITEM_ID, -1);
                    if (position >= 0) {
                        editEnforcer2.setText(DATA_USER.get(position).getName());
                        editEnforcerNo2.setText(DATA_USER.get(position).getNo());
                        surveyRecord.setEnforcer2(DATA_USER.get(position).getStrId());
                        surveyRecord.setEnforcerNo2(DATA_USER.get(position).getNo());
                    }
                }
                break;
            case REQUEST_TO_BOTTOM_MENU7:
                if (data != null) {
                    int position = data.getIntExtra(BottomMenuWindow.RESULT_ITEM_ID, -1);
                    if (position >= 0) {
                        editEnforcer3.setText(DATA_USER.get(position).getName());
                        editEnforcerNo3.setText(DATA_USER.get(position).getNo());
                        surveyRecord.setEnforcer3(DATA_USER.get(position).getStrId());
                        surveyRecord.setEnforcerNo3(DATA_USER.get(position).getNo());
                    }
                }
                break;

        }
    }


    @Override
    public void finish() {
        super.finish();

    }

    @Override
    public void onHttpResponse(int requestCode, String resultJson, Exception e) {

    }


    //类相关监听>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

    //系统自带监听方法>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>


    //Event事件区(只要存在事件监听代码就是)>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

    private OnClickListener onClickListener = new OnClickListener() {
        @Override
        public void onClick(View v) {
            switch (v.getId()) {
                case R.id.lay_survey_record:
                    break;
                case R.id.lay_exhaust_detection:

                    showShortToast("2");
                    break;
                case R.id.lay_emission_exceeding_standard:

                    showShortToast("3");
                    break;
            }
        }
    };


}